<%@ page import="com.touzi.constants.MobileCons" %>
<%@ page import="com.touzi.utils.MyHTTPUtils" %>
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="com.touzi.constants.DbCons" %>
<%@ page import="org.apache.ibatis.session.SqlSessionFactory" %>
<%@ page import="com.touzi.beans.dbs.users.User" %>
<%@ page import="java.util.List" %>
<%@ page import="com.touzi.beans.dbs.dingdan.AUserDingd" %>
<%@ page import="com.touzi.beans.dbs.liushui.Liushui" %>
<%@ page import="com.touzi.beans.dbs.yongjin.Yongjin" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.touzi.mapper.*" %><%--
  Created by IntelliJ IDEA.
  User: w7851
  Date: 2018/5/16
  Time: 7:49
  我的佣金页面
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%
    Cookie usercookie = MyHTTPUtils.getCookieByName(request, MobileCons.COOKIE_USERNAME);
    String userphone = usercookie.getValue();
    SqlSession sqlSession = ((SqlSessionFactory) application.getAttribute(DbCons.DB_FACTORY)).openSession();
    UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
    TongjiMapper tongjiMapper = sqlSession.getMapper(TongjiMapper.class);
    User user = userMapper.findUserByDhmw(userphone).get(0);
    String tuanduiyeji = tongjiMapper.getAUserYeji(user.id);

    List<User> yiji = userMapper.findYijXiashuByID(user.id);
    List<User> erji = userMapper.findErjXiashuByID(user.id);
    List<User> sanji = userMapper.findSanjXiashuByID(user.id);
    List<User> siji = userMapper.findSijXiashuByID(user.id);
    List<User> wuji = userMapper.findWujXiashuByID(user.id);
    List<User> liuji = userMapper.findLiujXiashuByID(user.id);
    List<User> qiji = userMapper.findQijXiashuByID(user.id);
    List<User> baji = userMapper.findBajXiashuByID(user.id);
    List<User> jiuji = userMapper.findJiujXiashuByID(user.id);
    List<User> shiji = userMapper.findShijXiashuByID(user.id);
    List<User> shiyiji = userMapper.findShiYijXiashuByID(user.id);
    List<User> shierji = userMapper.findShiErjXiashuByID(user.id);
    List<User> shisanji = userMapper.findShiSanjXiashuByID(user.id);

    List<User> all = new ArrayList<>();
    all.addAll(yiji);
    all.addAll(erji);
    all.addAll(sanji);
    all.addAll(siji);
    all.addAll(wuji);
    all.addAll(liuji);
    all.addAll(qiji);
    all.addAll(baji);
    all.addAll(jiuji);
    all.addAll(shiji);
    all.addAll(shiyiji);
    all.addAll(shierji);
    all.addAll(shisanji);
    for (User u : all) {
        if (u.cousumed.equals("yes")) {
            u.cousumed = "已消费";
        } else {
            u.cousumed = "未消费";
        }
        u.zhuceshijian = u.zhuceshijian.substring(5, 16);
    }

    sqlSession.close();
    request.setAttribute("yiji", yiji);
    request.setAttribute("erji", erji);
    request.setAttribute("sanji", sanji);
    request.setAttribute("siji", siji);
    request.setAttribute("wuji", wuji);
    request.setAttribute("liuji", liuji);
    request.setAttribute("qiji", qiji);
    request.setAttribute("baji", baji);
    request.setAttribute("jiuji", jiuji);
    request.setAttribute("shiji", shiji);
    request.setAttribute("shiyiji", shiyiji);
    request.setAttribute("shierji", shierji);
    request.setAttribute("shisanji", shisanji);

    request.setAttribute("user", user);
%>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的团队</title>
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>

    <meta content="yes" name="apple-mobile-web-app-capable"/>
    <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
    <meta content="telephone=no" name="format-detection"/>

    <link rel="stylesheet" href="/css/ydui.css">
    <script src="/js/ydui.flexible.js"></script>
</head>
<body>
<div class="g-flexview">
    <header class="m-navbar  navbar-fixed">
        <a onclick="goback()" class="navbar-item">
            <i class="back-ico"></i>
        </a>
        <div class="navbar-center"><span class="navbar-title">我的团队</span></div>
    </header>

    <div class="g-scrollview" style="margin-top: 1rem">

        <div class="m-celltitle">我直接推荐的人(只显示最新十条记录)</div>
        <div class="m-cell">
            <c:forEach var="item" items="${yiji}">
                <a class="cell-item" href="javascript:;">
                    <div class="cell-left">${item.id}←${item.tuijianren}&nbsp;(${item.zhuceshijian})</div>
                    <div class="cell-right">${item.cousumed}</div>
                </a>
            </c:forEach>
        </div>

        <div class="m-celltitle">我二级推荐的人</div>
        <div class="m-cell">
            <c:forEach var="item" items="${erji}">
                <a class="cell-item" href="javascript:;">
                    <div class="cell-left">${item.id}←${item.tuijianren}&nbsp;(${item.zhuceshijian})</div>
                    <div class="cell-right">${item.cousumed}</div>
                </a>
            </c:forEach>
        </div>

        <div class="m-celltitle">我三级推荐的人</div>
        <div class="m-cell">
            <c:forEach var="item" items="${sanji}">
                <a class="cell-item" href="javascript:;">
                    <div class="cell-left">${item.id}←${item.tuijianren}&nbsp;(${item.zhuceshijian})</div>
                    <div class="cell-right">${item.cousumed}</div>
                </a>
            </c:forEach>
        </div>

        <div class="m-celltitle">我四级推荐的人</div>
        <div class="m-cell">
            <c:forEach var="item" items="${siji}">
                <a class="cell-item" href="javascript:;">
                    <div class="cell-left">${item.id}←${item.tuijianren}&nbsp;(${item.zhuceshijian})</div>
                    <div class="cell-right">${item.cousumed}</div>
                </a>
            </c:forEach>
        </div>

        <div class="m-celltitle">我五级推荐的人</div>
        <div class="m-cell">
            <c:forEach var="item" items="${wuji}">
                <a class="cell-item" href="javascript:;">
                    <div class="cell-left">${item.id}←${item.tuijianren}&nbsp;(${item.zhuceshijian})</div>
                    <div class="cell-right">${item.cousumed}</div>
                </a>
            </c:forEach>
        </div>

        <div class="m-celltitle">我六级推荐的人</div>
        <div class="m-cell">
            <c:forEach var="item" items="${liuji}">
                <a class="cell-item" href="javascript:;">
                    <div class="cell-left">${item.id}←${item.tuijianren}&nbsp;(${item.zhuceshijian})</div>
                    <div class="cell-right">${item.cousumed}</div>
                </a>
            </c:forEach>
        </div>

        <div class="m-celltitle">我七级推荐的人</div>
        <div class="m-cell">
            <c:forEach var="item" items="${qiji}">
                <a class="cell-item" href="javascript:;">
                    <div class="cell-left">${item.id}←${item.tuijianren}&nbsp;(${item.zhuceshijian})</div>
                    <div class="cell-right">${item.cousumed}</div>
                </a>
            </c:forEach>
        </div>

        <div class="m-celltitle">我八级推荐的人</div>
        <div class="m-cell">
            <c:forEach var="item" items="${baji}">
                <a class="cell-item" href="javascript:;">
                    <div class="cell-left">${item.id}←${item.tuijianren}&nbsp;(${item.zhuceshijian})</div>
                    <div class="cell-right">${item.cousumed}</div>
                </a>
            </c:forEach>
        </div>

        <div class="m-celltitle">我九级推荐的人</div>
        <div class="m-cell">
            <c:forEach var="item" items="${jiuji}">
                <a class="cell-item" href="javascript:;">
                    <div class="cell-left">${item.id}←${item.tuijianren}&nbsp;(${item.zhuceshijian})</div>
                    <div class="cell-right">${item.cousumed}</div>
                </a>
            </c:forEach>
        </div>

        <div class="m-celltitle">我十级推荐的人</div>
        <div class="m-cell">
            <c:forEach var="item" items="${shiji}">
                <a class="cell-item" href="javascript:;">
                    <div class="cell-left">${item.id}←${item.tuijianren}&nbsp;(${item.zhuceshijian})</div>
                    <div class="cell-right">${item.cousumed}</div>
                </a>
            </c:forEach>
        </div>

        <div class="m-celltitle">我十一级推荐的人</div>
        <div class="m-cell">
            <c:forEach var="item" items="${shiyiji}">
                <a class="cell-item" href="javascript:;">
                    <div class="cell-left">${item.id}←${item.tuijianren}&nbsp;(${item.zhuceshijian})</div>
                    <div class="cell-right">${item.cousumed}</div>
                </a>
            </c:forEach>
        </div>

        <div class="m-celltitle">我十二级推荐的人</div>
        <div class="m-cell">
            <c:forEach var="item" items="${shierji}">
                <a class="cell-item" href="javascript:;">
                    <div class="cell-left">${item.id}←${item.tuijianren}&nbsp;(${item.zhuceshijian})</div>
                    <div class="cell-right">${item.cousumed}</div>
                </a>
            </c:forEach>
        </div>

        <div class="m-celltitle">我十三级推荐的人</div>
        <div class="m-cell">
            <c:forEach var="item" items="${shisanji}">
                <a class="cell-item" href="javascript:;">
                    <div class="cell-left">${item.id}←${item.tuijianren}&nbsp;(${item.zhuceshijian})</div>
                    <div class="cell-right">${item.cousumed}</div>
                </a>
            </c:forEach>
        </div>

    </div>
</div>
</body>
<script>
    function goback() {
        history.go(-1);
    }
</script>
</html>
